﻿using MainService;
using MainService.ZNQD;
using MainService.ZYPT;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
namespace MyTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            //NewMethod();
            //ZYLB zylb = ZYPTServer.GetZYLB(); 
            //MoShi moshi = ZYPTServer.GetMoShi();
            //ZYPTServer.GetZuJian("3");
             //ZJS zjs= ZYPTServer.GetZuJian("14");
             //XmlSerializer xs = new XmlSerializer(typeof(ZJS));
             //using(FileStream fs=new FileStream("C:\\1.xml",FileMode.Create))
             //{
             //    xs.Serialize(fs, zjs);
             //}
             //Application.Exit();
            Solutions solutions = ZNQDServer.GetSolutionList();
            Solution solution = (from m in solutions.list where m.Version != null select m).First();
            string id = solution.SolutionID;
            string version = solution.Version;
            ZNQDServer.GetSolutionInfo(id, version);
        }

        //private void NewMethod()
        //{
        //    WebClient webclient = new WebClient();
        //    WebReference.ResourceTypeService rts = new WebReference.ResourceTypeService();
        //    string xml = rts.qryAllResourceType();
        //    XmlDocument doc = new XmlDocument();
        //    doc.LoadXml(xml);
        //    ImageList IL = new ImageList();
        //    XmlNode root = doc.DocumentElement;
        //    foreach (XmlNode item in root.ChildNodes)
        //    {
        //        string text = item.Attributes["Name"].Value;
        //        string description = item.Attributes["Description"].Value;
        //        string url = "http://10.72.36.6:8080/rcenter/imgView/showImg/5a44c7ba5bbe4ec867233d67e4806848.jpg";
        //        string filename = Path.GetFileName(url);
        //        if (!IL.Images.ContainsKey(filename))
        //        {
        //            string filepath = "C:\\Imgtem\\" + filename;
        //            webclient.DownloadFile(url, filepath);
        //            Image img = Image.FromFile(filepath);
        //            IL.Images.Add(filename, img);
        //        }
        //        TreeNode node = new TreeNode();
        //        node.Text = text;
        //        node.ToolTipText = description;
        //        node.ImageKey = filename;
        //        MyTree.Nodes.Add(node);
        //        ReaderChilde(node, item, IL, webclient);
        //    }
        //    MyTree.ImageList = IL;
        //    MyTree.ExpandAll();
        //}

        //private void ReaderChilde(TreeNode rootnode, XmlNode root, ImageList IL, WebClient webclient)
        //{
        //    foreach (XmlNode item in root.ChildNodes)
        //    {
        //        string text = item.Attributes["Name"].Value;
        //        string description = item.Attributes["Description"].Value;
        //        string url = "http://10.72.36.6:8080/rcenter/imgView/showImg/5a44c7ba5bbe4ec867233d67e4806848.jpg";
        //        string filename = Path.GetFileName(url);
        //        if (!IL.Images.ContainsKey(filename))
        //        {
        //            string filepath = "C:\\Imgtem\\" + filename;
        //            webclient.DownloadFile(url, filepath);
        //            Image img = Image.FromFile(filepath);
        //            IL.Images.Add(filename, img);
        //        }
        //        TreeNode node = new TreeNode();
        //        node.Text = text;
        //        node.ToolTipText = description;
        //        node.ImageKey = filename;
        //        rootnode.Nodes.Add(node);
        //        ReaderChilde(node, item, IL, webclient);
        //    }
        //}
    }
}
